package org.jetnuke.test.blocks;

import org.apache.log4j.Logger;

import java.util.Random;

import javax.servlet.http.HttpServletRequest;

import org.apache.velocity.VelocityContext;
import org.jetnuke.common.IAdminInfo;
import org.jetnuke.common.IBlock;
import org.jetnuke.common.IBlockInfo;
import org.jetnuke.common.IUserInfo;

public class HelloWorldDyn implements IBlock {
	/**
	 * Logger for this class
	 */
	private static final Logger logger = Logger.getLogger(HelloWorldDyn.class);

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.common.IBlock#serviceBlock(javax.servlet.http.HttpServletRequest,
	 *      org.apache.velocity.VelocityContext, org.jetnuke.common.IBlockInfo,
	 *      org.jetnuke.common.IUserInfo, org.jetnuke.common.IAdminInfo)
	 */
	public void serviceBlock(HttpServletRequest req, VelocityContext vc,
			IBlockInfo blockInfo, IUserInfo userInfo, IAdminInfo adminInfo)
			throws Exception {
		if (logger.isDebugEnabled()) {
			logger
					.debug("serviceBlock(HttpServletRequest, VelocityContext, IBlockInfo, IUserInfo, IAdminInfo) - start"); //$NON-NLS-1$
		}

		vc.put("hello_world_key", new Integer(new Random().nextInt()));

		if (logger.isDebugEnabled()) {
			logger
					.debug("serviceBlock(HttpServletRequest, VelocityContext, IBlockInfo, IUserInfo, IAdminInfo) - end"); //$NON-NLS-1$
		}
	}

}
